# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=imbalanced-learn
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.11.0
pkgrel=1
pkgdesc="A Python Package to Tackle the Curse of Imbalanced Datasets in Machine Learning (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/scikit-learn-contrib/imbalanced-learn'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-joblib"
         "${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-scikit-learn"
         "${MINGW_PACKAGE_PREFIX}-python-scipy"
         "${MINGW_PACKAGE_PREFIX}-python-threadpoolctl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cython")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-keras"
            "${MINGW_PACKAGE_PREFIX}-python-tensoflow")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7582ae8858e6db0b92fef97dd08660a18297ee128d78c2abdc006b8bd86b8fdc')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -D LICENSE "$pkgdir"/${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
